Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using PolySharp to allow use of C#13 #132

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from

Conversation

DennisDyallo
Copy link
Collaborator

@DennisDyallo DennisDyallo commented Jul 30, 2024

Description

This update removes the need for the Yubico.DotnetPolyfills-project. This project was adding a couple of methods, such as the Range and the Index operator. Now, since adding Polysharp, this is no longer needed as Polysharp generates polyfills for newer C# language features and APIs at compile-time. This also allows us to use C# language version 13 instead of 7.3.

Examples of new syntax can be seen here in a stowed away branch in this repo.

Note
It's true that bringing in a dependency into any library should not be taken in lightly. This suggestion has been with the team for some time, and while we haven't committed to it yet, we want to explore the possibility of making such a change. We do believe measures can be taken to ensure stability and expected behavior. Rest assured, although the third party dependency in question appears to be well regarded, useful and stable, it won't be added without going through a due dilligence process.

To anyone else reading this, please feel free to add your comments or any alternatives to move the SDK forward in this regard.

Fixes: YESDK1316

Type of change

How has this been tested?

Unit tests pass and builds pass.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have run dotnet format to format my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@DennisDyallo DennisDyallo changed the title Replaceing Yubico.DotnetPolyFills with PolySharp Replacing Yubico.DotnetPolyFills with PolySharp Jul 30, 2024
Copy link

github-actions bot commented Jul 30, 2024

Test Results: Windows

    2 files      2 suites   4s ⏱️
3 777 tests 3 777 ✅ 0 💤 0 ❌
3 779 runs  3 779 ✅ 0 💤 0 ❌

Results for commit 8c4428c.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 30, 2024

Test Results: Ubuntu

    2 files      2 suites   5s ⏱️
3 769 tests 3 769 ✅ 0 💤 0 ❌
3 771 runs  3 771 ✅ 0 💤 0 ❌

Results for commit 8c4428c.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Jul 30, 2024

Test Results: MacOS

    2 files      2 suites   5s ⏱️
3 769 tests 3 769 ✅ 0 💤 0 ❌
3 771 runs  3 771 ✅ 0 💤 0 ❌

Results for commit 8c4428c.

♻️ This comment has been updated with latest results.

@DennisDyallo DennisDyallo changed the title Replacing Yubico.DotnetPolyFills with PolySharp Replacing Yubico.DotnetPolyFills with PolySharp. Bumping LanguageVersion to C#12. Jul 30, 2024
@iamcarbon
Copy link

This introduces an untrusted third party dependency into a security critical library. It would be better to selectively port the individual Polyfills into core, then introduce a new dependency (and extend the chain of trust).

@DennisDyallo
Copy link
Collaborator Author

DennisDyallo commented Aug 27, 2024

This introduces an untrusted third party dependency into a security critical library. It would be better to selectively port the individual Polyfills into core, then introduce a new dependency (and extend the chain of trust).

Hi @iamcarbon and thanks for your raised concern. It's true that bringing in a dependency into any library should not be taken in lightly. This suggestion has been with the team for some time, and while we haven't committed to it yet, we want to explore the possibility of making such a change. We do believe measures can be taken to ensure stability and expected behavior. Rest assured, although the third party dependency in question appears to be well regarded, useful and stable, it won't be added without going through a due dilligence process.

To you and anyone else reading this, please feel free to add your comments or any alternatives to move the SDK forward in this regard.

@dainnilsson @GregDomzalski FYI

Update target framework to .NET 9.0

Updated the target framework from .NET 6.0 to .NET 9.0.
Added a commented-out section in the project file with
instructions for testing against local changes to the
YubiKey library, including a `ProjectReference` to a
local YubiKey project file.
@DennisDyallo DennisDyallo changed the title Replacing Yubico.DotnetPolyFills with PolySharp. Bumping LanguageVersion to C#12. Using PolySharp to allow use of C#13 Jan 13, 2025
@DennisDyallo DennisDyallo marked this pull request as ready for review February 6, 2025 10:09
@DennisDyallo DennisDyallo force-pushed the dennisdyallo/polysharp branch from f41b4b1 to 4b413c4 Compare February 13, 2025 06:27
@@ -88,7 +88,7 @@ public void AuthKey_Aes_Succeeds()
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58
};

var initCmd = new InitializeAuthenticateManagementKeyCommand(true, PivAlgorithm.TripleDes);
var initCmd = new InitializeAuthenticateManagementKeyCommand(true, PivAlgorithm.TripleDes); // TODO this test only works with 5.4.3 and lower
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will handle this in test rework case

Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
Yubico.Core 40% 31% 4311
Yubico.YubiKey 50% 46% 19632
Summary 48% (33138 / 69216) 44% (8226 / 18903) 23943

Minimum allowed line rate is 40%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants